import {Component, OnInit} from '@angular/core';
import {Subscription} from "rxjs/Subscription";
import {ActivatedRoute, Router} from "@angular/router";
import {MatchService} from "../match.service";




@Component({
  selector: 'match-brand',
  templateUrl: './match-brand.component.html',
  styleUrls: ['./match-brand.component.scss']
})
export class MatchBrandComponent implements OnInit {
  subscription: Subscription = new Subscription();
  public matchBrand: any;
  public isBrand: string;

  constructor(public router: Router,
              public route: ActivatedRoute,
              public matchService: MatchService) {
    this.isBrand = matchService.backUp.recomName;
  }

  goBack() {
    this.router.navigate(['/match/filter']);
  }

  brandSubmit(id, name): void {
    this.isBrand = name;
    this.matchService.backUp.matchIpRecomId = id;
    this.matchService.backUp.recomName = name;
    this.router.navigate(['/match/filter']);
  }

  ngOnInit() {
    const whole = {
      "nickName": "全部",
      "userId": null
    };
    this.matchBrand = this.matchService.event_recoms;
    this.matchBrand.unshift(whole);
  }

}
